//
//  LLT_RankListViewController_LXM.m
//  CoderLLT
//
//  Created by 刘晓萌 on 15/12/12.
//  Copyright © 2015年 刘晓萌. All rights reserved.
//

#import "LLT_RankListViewController_LXM.h"
#import "LLT_PlayerInfoViewController_LXM.h"
@interface LLT_RankListViewController_LXM ()<UIWebViewDelegate>

@property (weak, nonatomic) IBOutlet UIWebView *rankListWebView;

@end

@implementation LLT_RankListViewController_LXM

- (void)viewDidLoad {
    [super viewDidLoad];
    self.rankListWebView.delegate = self;
    [self.rankListWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://static.lolmax.com/api/static/lol/pages/rank/rankList.html"]]];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


/**
 * uiwebView按状态响应加载
 *
 * @return
 */
#pragma mark --- uiwebView 协议
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSString *str = [request URL].absoluteString;
    str = [str stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    NSString *strsub = [str substringToIndex:6];
    NSString *s = @"maxjia://OpenPlayerInfo#/";
    if ([strsub isEqualToString:@"maxjia"]) {
        str =  [str stringByReplacingOccurrencesOfString:s withString:@""];
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding:NSUTF8StringEncoding]
                                                            options: NSJSONReadingMutableContainers
                                                              error: nil];
        NSDictionary *dic_sub = dic[@"result"];
        LLT_PlayerModel *player = [LLT_PlayerModel new];
        player.playerName = dic_sub[@"user_id"];
        for (NSString *key in player.serverDic) {
            if ([player.serverDic[key] isEqualToString:dic_sub[@"area_id"]]) {
                player.serverName =key;
            }
        }
        LLT_PlayerInfoViewController_LXM *pInfoVC = [MainStoryBoard instantiateViewControllerWithIdentifier:@"playerInfoVC"];
        pInfoVC.player = player;
        pInfoVC.showFlag = YES;
        [self presentViewController:pInfoVC animated:YES completion:nil];
    }
    return YES;
}

/**
 * 设置电源栏反颜色
 *
 * @return
 */
- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

/**
 * 点击左侧返回
 */
- (IBAction)didClickLeftButton:(UIButton *)sender {
    DissMissBack;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
